/*
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef EPUB_ELEMENT_H_
#define EPUB_ELEMENT_H_

// Abiword includes
#include <ut_string.h>
#include <ut_hash.h>
#include <ut_string_class.h>

// External includes
#include <boost/shared_ptr.hpp>
#include <vector>

/**
 * EPUB Document Element Supported Types
 */
enum EDE_Type
{
	EDE_Hyperlink,
	EDE_Image,
	EDE_Paragraph,
	EDE_Span,
	EDE_OrderedList,
	EDE_UnorderedList,
	EDE_ListItem,
	EDE_Table,
	EDE_TableRow,
	EDE_TableCell,
	EDE_Html,
	EDE_Head,
	EDE_Body,
	EDE_Title,
	EDE_Div
};

class EPUB_Element;
typedef boost::shared_ptr<EPUB_Element> EPUB_Shared_Element;

/**
 * Class that represents element of the EPUB document, in fact
 * it`s just DOM element
 */
class EPUB_Element
{
public:
	EPUB_Element(EDE_Type type, const UT_UTF8String& value = UT_UTF8String());

	/**
	 * Returns element`s level in DOM tree
	 */
	int getLevel() const;

	/**
	 * Returns element type
	 */
	EDE_Type getType() const;
	/**
	 * Returns element value
	 */
	const UT_UTF8String &getValue() const;
	/**
	 * Returns element name
	 */
	const UT_UTF8String  &getName() const;
	/**
	 * Returns attribute map of the element
	 */
	UT_GenericStringMap<UT_UTF8String*>& getAttributes();
	/**
	 * Returns element`s child nodes
	 */
	std::vector<EPUB_Shared_Element>& getChildren();

	/**
	 * Sets specified attribute value for the element
	 */
	void setAttribute(const UT_String &attribute, UT_UTF8String *value);
	/**
	 * Sets element`s type
	 */
	void setType(EDE_Type type);
	/**
	 * Sets element`s value
	 */
	void setValue(const UT_UTF8String &value);
	/**
	 * Adds child to the element
	 */

	/**
	 * Set`s level of current element and all of it`s child respectively
	 */
	void setLevel(int level);

	void addChild(const EPUB_Shared_Element & child);

	static UT_UTF8String GetNameByType(EDE_Type type);
	~EPUB_Element();
private:
	EDE_Type m_type;
	UT_UTF8String m_value;
	/**
	 * Element level in tree
	 */
	int m_level;
	UT_UTF8String m_name;
	UT_GenericStringMap<UT_UTF8String*> m_attributes;
	std::vector<EPUB_Shared_Element> m_children;
};

#endif /* EPUB_DOCUMENT_H_ */
